package com.bi.onlineEducation.domain;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;

/**
 * course_path
 *
 * @author
 */
@Entity
@Table(name = "course_path")
@ApiModel(value = "generate.CoursePath与课程表是多对一的关系")
@Data
@Accessors(chain = true)
public class CoursePathPo implements Serializable {
    /**
     * 课程路径主键ID
     */
    @Id
    @Column(name = "cp_id")
    @GeneratedValue(generator = "JDBC")
    @ApiModelProperty(value = "课程路径主键ID")
    private Integer cpId;

    /**
     * 课程路径名称
     */
    @Column(name = "cp_name")
    @ApiModelProperty(value = "课程路径名称")
    private String cpName;

    /**
     * 课程播放路径
     */
    @Column(name = "cp_path")
    @ApiModelProperty(value = "课程播放路径")
    private String cpPath;

    /**
     * 播放量
     */
    @Column(name = "play_amount")
    @ApiModelProperty(value = "播放量")
    private Integer playAmount;

    /**
     * 时长
     */
    @Column(name = "cp_duration")
    @ApiModelProperty(value = "时长")
    private Integer cpDuration;

    /**
     * 缩略图路径
     */
    @Column(name = "thumb_path")
    @ApiModelProperty(value = "缩略图路径")
    private String thumbPath;

    /**
     * 所属课程
     */
    @Column(name = "c_id")
    @ApiModelProperty(value = "所属课程")
    private Integer cId;

    @OneToOne(cascade = CascadeType.DETACH)//PurchasePo是关系的维护端，当删除 PurchasePo，会级联删除 CoursePo
    @JoinColumn(name = "c_id", referencedColumnName = "c_id", insertable = false, updatable = false)
    @JsonIgnoreProperties({"courseType", "login"})
    private CoursePo course;    //PurchasePo中的c_id字段参考CoursePo表中的id字段

    /**
     * 上传时间
     */
    @Column(name = "upload_time")
    @ApiModelProperty(value = "上传时间")
    private Date uploadTime;

    /**
     * 上传人
     */
    @Column(name = "l_id")
    @ApiModelProperty(value = "上传人")
    private Integer lId;

    @OneToOne(cascade = CascadeType.DETACH)//PurchasePo是关系的维护端，当删除 PurchasePo，会级联删除 CoursePo
    @JoinColumn(name = "l_id", referencedColumnName = "l_id", insertable = false, updatable = false)
    private LoginPo login;    //PurchasePo中的c_id字段参考CoursePo表中的id字段

    private static final long serialVersionUID = 1L;
}